package com.ss.android.article.base.feature.subscribe.model;

import android.os.Parcel;
import android.os.Parcelable;

import com.bytedance.common.utility.collection.e;
import com.ss.android.article.common.share.interf.IShareEntryItemBean;
import com.ss.android.common.AbsApiThread;
import com.ss.android.newmedia.BaseAppData;

import org.json.JSONObject;

import java.util.concurrent.atomic.AtomicInteger;

public class EntryItem implements Parcelable, IShareEntryItemBean {
    public static final Parcelable.Creator CREATOR;
    public static final int TYPE_CATEGORY = 2;
    public static final int TYPE_CITY = 3;
    public static final int TYPE_PGC_MEDIA = 1;
    public static final int TYPE_TOPIC = 4;
    public static final int TYPE_WAP = 5;
    public String mDescription;
    public long mGroupId;
    public String mIconUrl;
    public final long mId;
    private transient boolean mIdOnly;
    public transient boolean mIsLoading;
    public String mLabel;
    public int mLabelStyle;
    public String mName;
    public int mPosition;
    public String mShareUrl;
    public boolean mShowNewTip;
    private transient int mSubTag;
    public int mSubscribeCount;
    private boolean mSubscribed;
    public int mType;
    public long mUserId;
    public String mWapUrl;
    private static e sEntryMapCache;
    private static AtomicInteger sSubTagGlobal;

    static {
        EntryItem.sSubTagGlobal = new AtomicInteger();
        CREATOR = new c();
        EntryItem.sEntryMapCache = new e();
    }

    private EntryItem(long arg4, boolean arg6) {

        this.mPosition = -1;
        this.mIsLoading = false;
        this.mSubTag = 0;
        this.mIdOnly = false;
        this.mId = arg4;
        this.mSubTag = EntryItem.sSubTagGlobal.get();
        this.mIdOnly = arg6;
    }

    protected EntryItem(Parcel arg7) {
        boolean v1 = true;

        this.mPosition = -1;
        this.mIsLoading = false;
        this.mSubTag = 0;
        this.mIdOnly = false;
        this.mId = arg7.readLong();
        this.mType = arg7.readInt();
        this.mName = arg7.readString();
        this.mDescription = arg7.readString();
        this.mIconUrl = arg7.readString();
        this.mSubscribeCount = arg7.readInt();
        boolean v0 = arg7.readByte() != 0 ? true : false;
        this.mSubscribed = v0;
        if (arg7.readByte() == 0) {
            v1 = false;
        }

        this.mShowNewTip = v1;
        this.mWapUrl = arg7.readString();
        this.mGroupId = arg7.readLong();
        this.mPosition = arg7.readInt();
        this.mShareUrl = arg7.readString();
        this.mLabelStyle = arg7.readInt();
        this.mLabel = arg7.readString();
        this.mUserId = arg7.readLong();
    }

    public static void clearAllSubscribeFlag() {
        EntryItem.sSubTagGlobal.incrementAndGet();
    }

    public int describeContents() {
        return 0;
    }

    public boolean equals(Object arg7) {
        boolean v0 = true;
        if (this != (((EntryItem) arg7))) {
            if (arg7 == null) {
                v0 = false;
            } else if (this.getClass() != arg7.getClass()) {
                v0 = false;
            } else if (this.mId != ((EntryItem) arg7).mId) {
                v0 = false;
            }
        }

        return v0;
    }

    public void extractFields(JSONObject arg3) {
        if (arg3 != null) {
            this.mType = arg3.optInt("type");
            this.mName = arg3.optString("name");
            this.mDescription = arg3.optString("description");
            this.mIconUrl = arg3.optString("icon");
            this.mSubscribeCount = arg3.optInt("subscribe_count");
            this.setSubscribed(AbsApiThread.optBoolean(arg3, "is_subscribed", false));
            this.mShowNewTip = AbsApiThread.optBoolean(arg3, "tip_new", false);
            this.mGroupId = arg3.optLong("group_id");
            this.mWapUrl = arg3.optString("url");
            this.mPosition = arg3.optInt("index", -1);
            this.mLabel = arg3.optString("label");
            this.mLabelStyle = arg3.optInt("label_style");
            this.mShareUrl = arg3.optString("share_url");
            this.mUserId = arg3.optLong("user_id");
        }
    }

    public String getDescription() {
        return this.mDescription;
    }

    public static EntryItem getFake(long arg2) {
        return new EntryItem(arg2, true);
    }

    public String getIconUrl() {
        return this.mIconUrl;
    }

    public long getId() {
        return this.mId;
    }

    public String getName() {
        return this.mName;
    }

    public String getShareUrl() {
        return this.mShareUrl;
    }

    public int getUseImage4QQShare() {
        return BaseAppData.inst().useImageQqShare();
    }

    public long getUserId() {
        return this.mUserId;
    }

    public int hashCode() {
        return (((int) (this.mId ^ this.mId >>> 32))) + 31;
    }

    public boolean isIdOnly() {
        return this.mIdOnly;
    }

    public boolean isSubscribed() {
        return this.mSubscribed && this.mSubTag == EntryItem.sSubTagGlobal.get();
    }

    public static synchronized EntryItem obtain(long arg4) {
        EntryItem entryItem;
        entryItem = (EntryItem) EntryItem.sEntryMapCache.a(Long.valueOf(arg4));
        if (entryItem == null) {
            entryItem = new EntryItem(arg4, false);
            EntryItem.sEntryMapCache.a(Long.valueOf(arg4), entryItem);
        }
        return entryItem;
    }

    public static EntryItem optObtain(long arg4) {
        Class v1 = EntryItem.class;
        synchronized (v1) {
            return (EntryItem) EntryItem.sEntryMapCache.a(Long.valueOf(arg4));
        }
    }

    public void setSubscribed(boolean subscribed) {
        this.mSubscribed = subscribed;
        if (this.mSubTag != EntryItem.sSubTagGlobal.get()) {
            this.mSubTag = EntryItem.sSubTagGlobal.get();
        }
    }

    public String toString() {
        return "EntryItem [mId=" + this.mId
                + ", mType=" + this.mType
                + ", mName=" + this.mName
                + ", mDescription=" + this.mDescription
                + ", mIconUrl=" + this.mIconUrl
                + ", mSubscribeCount=" + this.mSubscribeCount
                + ", mSubscribed=" + this.mSubscribed
                + ", mShowNewTip=" + this.mShowNewTip
                + ", mPosition=" + this.mPosition
                + ", mIsLoading=" + this.mIsLoading
                + ", mLabelStyle=" + this.mLabelStyle
                + ", mLabel=" + this.mLabel
                + ", mUserId=" + this.mUserId + "]";
    }

    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeLong(this.mId);
        parcel.writeInt(this.mType);
        parcel.writeString(this.mName);
        parcel.writeString(this.mDescription);
        parcel.writeString(this.mIconUrl);
        parcel.writeInt(this.mSubscribeCount);
        parcel.writeByte((byte) (this.mSubscribed ? 1 : 0));
        parcel.writeByte((byte) (this.mShowNewTip ? 1 : 0));
        parcel.writeString(this.mWapUrl);
        parcel.writeLong(this.mGroupId);
        parcel.writeInt(this.mPosition);
        parcel.writeString(this.mShareUrl);
        parcel.writeInt(this.mLabelStyle);
        parcel.writeString(this.mLabel);
        parcel.writeLong(this.mUserId);
    }
}

